/*
  柯里化案例
*/
const _ = require('lodash')

const match = _.curry(function (reg, str) {
  return str.match(reg)
})

const haveSpace = match(/\s+/g)
const haveNumber = match(/\d+/g)

// console.log(haveSpace('Hello World'))
// console.log(haveNumber('Hello1 World'))

// 过滤数组中的空格元素
const filter = _.curry(function (func, array) {
  return array.filter(func)
})

console.log(filter(haveSpace, ['a b', 'cd']))

const findSpace = filter(haveSpace)
console.log(findSpace(['a b', 'cd']))
